package Views;


import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import Controllers.MainController;

public class Test1View extends MasterView implements ActionListener{
	
	/*
	 * Pour tester
	 */
	private JFrame frame = null;
	private JPanel contentPane = null;
	private JButton button = null;
	private JButton button2 = null;
	private JButton undobutton = null;
	private JTextField text = null;
	/*
	 *  ---------------------
	 */
	
	public Test1View(MainController controller) {
		super(controller);
		// TODO Auto-generated constructor stub
		
		// TODO takes input the ArrayList that contains the "Livraisons" and all the necessary information 
		// to make the graph
		frame = new JFrame();
		contentPane = new JPanel();
		buildFrame();
	}
	
	//Test Instructions just to show a test Frame
	public void buildFrame(){

		button = new JButton("Ajouter Livraision: ID: 2");
		button2 = new JButton("Suprimer Livraison: ID: 4");
		undobutton = new JButton("Undo Changes!");
		text = new JTextField(20);
		
		button.addActionListener(this);
		button2.addActionListener(this);
		undobutton.addActionListener(this);
		
		button.setActionCommand("Ajouter");
		button2.setActionCommand("Supprimer");
		undobutton.setActionCommand("Undo");
		
		contentPane.add(button);
		contentPane.add(button2);
		contentPane.add(text);
		
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setContentPane(contentPane);
		frame.setTitle("JFrameSpinnerVolume");
		frame.pack();
		frame.setSize(400, 400);
	}

	@Override
	public void display() {
		// TODO Auto-generated method stub
		frame.setVisible(true);
	}

	@Override
	public void close() {
		// TODO Auto-generated method stub
		frame.dispose();	
	}
	
//	public void volumeChanged(VolumeChangedEvent event) {
//		field.setValue(event.getNewVolume());
//	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		// getController().something() ;
		System.out.println(e.getActionCommand());
		if(e.getActionCommand().equals("Ajouter")){
			//getController().ChangeIntersectionState("Salut", 2);
			getController().TestAction2();
		}
	}
	
	/*
	 * just for testing - adding undo button when i get the reply > Model > Controller > view
	 */
	
	public void showUndoRedo(){
		//contentPane.add(undobutton);
		text.setText("Action Received from Model");
		System.out.println("Action Returend from Model > Controller >  View");
	}
	
	

} //end class class Test1View
